﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sample
{
    public partial class DialogBox : Form
    {
        public Action<ushort> Execute;
        // public Func<string, bool> Execute;
        public DialogBox(string title,string lbl)
        {
      
            InitializeComponent();
            this.Text = title;
            label1.Text = lbl;
        }

        private void sure_btn_Click(object sender, EventArgs e)
        {
            bool state = false;
            ushort temp = 0;
            try
            {
                  temp = Convert.ToUInt16(number_txt.Text);
                state = true;
            }
            catch (Exception)
            {
                MessageBox.Show(@"请输入正确的 Uint 16值");
            }
            if (state)
            {
                Execute(temp);
                Close();

            }
       


        }

        private void DialogBox_Load(object sender, EventArgs e)
        {


        }
    }
}
